package com.clock.controller.stage;


import com.clock.common.domain.R;
import com.clock.domain.entity.DailyRecord;
import com.clock.service.DailyRecordService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@Api(tags = {"日常学习接口"})
@RestController
@RequestMapping("dailyRecord")
public class DailyRecordController {

    @Resource
    DailyRecordService dailyRecordService;


    @ApiOperation(value = "接收学习时间记录", notes = "需要做参数校验")
    @PostMapping("/newRecord")
    public R insertNewStudyRecord(@RequestBody @Validated DailyRecord dailyRecord) {
        return dailyRecordService.addNewStudyRecord(dailyRecord);
    }

    @ApiOperation(value = "查询学习记录")
    @PostMapping("/records/{userId}/{pageNum}/{pageSize}")
    public R queryStudyRecordsByLimit(@PathVariable("userId") Long userId, @PathVariable("pageNum") Integer pageNum, @PathVariable("pageSize") Integer pageSize) {

        return dailyRecordService.queryRecordsByUserId(userId, pageNum, pageSize);
    }

}
